export default {
  // state: 用来保存所有的公共数据
  namespaced: true, 
  state(){
   return {
    goodsList:[
      {id:1,name:'手机',price:2000},
      {id:2,name:'电脑',price:20000}
     ]
   }
  },
  getters: {
    goodsSum(state){
    return  state.goodsList.reduce((sum,item)=>sum+item.price,0)
    }
  },
  mutations: {
    addGoods(state,book){
        state.goodsList.push(book)
    }
  },
  actions: {},
}